import { getLanguage, setLanguage, useLang } from "i18n-use";
import { useState } from "react";
import { Link } from "react-router-dom";

import fire from "@/assets/fire.png";

import styles from "./index.module.css";

function Home() {
  const [count, setCount] = useState(false);
  const { t } = useLang("home");
  const changeLang = () => {
    setLanguage(getLanguage() == "zh" ? "in" : "zh");
    setCount(!count);
  };
  return (
    <div>
      <h2>Home 首页</h2>
      <Link to="/test">跳转到test</Link>
      <ul>
        <li>翻译内容：{t("姓名")}</li>
        <li>
          动态翻译内容：
          {t("年龄{age}", {
            age: 18,
          })}
        </li>
      </ul>
      <p onClick={changeLang}>切换语言{getLanguage()}</p>
      <img className={styles["fire"]} src={fire} alt="" />
    </div>
  );
}

export default Home;
